#ifndef __GlSection_h__
#define __GlSection_h__

#include <vector>
#include "GlMain.h"
#include "GlPosition.h"

namespace GraphicLibrary
{
	class GlExport Section
	{
		public:
			Position	mBegin;
			Position	mEnd;
			inline Section()
			{}
			inline Section(const Position &begin, const Position &end)
				: mBegin(begin)
				, mEnd(end)
			{}
			inline Position lerp(const float perc) const	{return mBegin * perc + mEnd * (1.0f - perc);}
			inline float length() const						{return (mEnd - mBegin).length();}
			void scale(float perc);
			inline bool operator == (const Section &other) const	{return mBegin == other.mBegin && mEnd == other.mEnd;}
			inline bool operator != (const Section &other) const	{return !operator == (other);}
			static bool GetIntersection(const Section &first, const Section &second, Position *intersection);
	};

	class GlExport SectionArray
		: public std::vector<Section>
	{
		public:
			void add(const Section &section);
			void remove(const Section &section);
			iterator findPlace(const Section &section);
	};
}

#endif // __GlSection_h__
